package cn.soft863.users.test;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import cn.soft863.common.util.PageInfoUtil;
import cn.soft863.users.pojo.AOrdersHistory;
import cn.soft863.users.service.MenuService;
import cn.soft863.users.service.OrdersHistoryService;
import cn.soft863.users.service.impl.MenuServiceImpl;
import cn.soft863.users.service.impl.OrdersHistoryServiceImpl;

public class AOrsersHis
{
	private OrdersHistoryService menuService = new OrdersHistoryServiceImpl();

	public void findCondListmenuService()
	{
		PageInfoUtil pageInfoUtil = new PageInfoUtil() ; 
		pageInfoUtil.setPageSize(10);
		pageInfoUtil.setCurrentPage(1);
		
		/**
		 * 查询条件
		 * 
		 * 键:指的是查询条件的分类:在Dao使用代码的地方看出来的.
		 * 值:就是用户输入的关键字
		 */
		Map<String, Object> condMap = new HashMap<String, Object>();
		/* 按照关键字查询 */
		condMap.put("keyword", "s");
		/* 按照状态查询 */
		/*condMap.put("status", "1");*/
		/* 查询最近一个月的 
		 * 起始时间:2017-08-18 00:00:00
		 * 结束时间:2017-09-19 00:00:00
		 * */
		/*Calendar calendar = Calendar.getInstance() ; 
		calendar.set(Calendar.HOUR_OF_DAY, 0);
		calendar.set(Calendar.MINUTE, 0);
		calendar.set(Calendar.SECOND, 0);
		Date edDate = calendar.getTime() ; 
		calendar.add(Calendar.MONTH, -1);
		Date stDate = calendar.getTime() ; 
		System.out.println(stDate.toLocaleString() + "---->" + edDate.toLocaleString());
		condMap.put("stDate", stDate);
		condMap.put("edDate", edDate);*/
		
		/**
		 * 终于将查询的结果放到了集合中
		 */
		/*List<AOrdersHistory> menuList = this.menuService.findCondListmenuService(null);*/
		List<AOrdersHistory> menuList = this.menuService.findCondListorderHistoryService(pageInfoUtil,condMap);
		for (Iterator iterator = menuList.iterator(); iterator.hasNext();)
		{
			AOrdersHistory menu = (AOrdersHistory) iterator.next();
			System.out.println(menu.getContent());
		}
		System.out.println("分页的信息:总页数:" + pageInfoUtil.getTotalPage() + ",总条数:" + pageInfoUtil.getTotalRecord()
				+ ",当前页:" + pageInfoUtil.getCurrentPage() );
	}
	public static void main(String[] args)
	{
		System.out.println("======");
		
		AOrsersHis aOrsersHis = new AOrsersHis() ; 
	
		//menuServiceTest.updateOnemenuService();
		
		//menuServiceTest.saveOnemenuService();
		//menuServiceTest.saveBatchmenuService();
		
		aOrsersHis.findCondListmenuService();
	
		
	}
	
}
